package com.ruoyi.web.controller.sj.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sj.domain.QuickHelp;
import com.ruoyi.sj.service.IQuickHelpService;
import com.ruoyi.web.core.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;

/**
 * 帮助详情 信息操作处理
 * 
 * @author tyc@yanyu.com
 * @date 2018-11-30
 */
@Controller
@RequestMapping("/sj/quickHelp")
public class QuickHelpController extends BaseController
{
    private String prefix = "sj/quickHelp";
	
	@Autowired
	private IQuickHelpService quickHelpService;
	
	@RequiresPermissions("sj:quickHelp:view")
	@GetMapping()
	public String quickHelp()
	{
	    return prefix + "/quickHelp";
	}
	
	/**
	 * 查询帮助详情列表
	 */
	@RequiresPermissions("sj:quickHelp:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(QuickHelp quickHelp)
	{
		startPage();
        List<QuickHelp> list = quickHelpService.selectQuickHelpList(quickHelp);
		return getDataTable(list);
	}
	
	/**
	 * 新增帮助详情
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存帮助详情
	 */
	@RequiresPermissions("sj:quickHelp:add")
	@Log(title = "帮助详情", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(QuickHelp quickHelp)
	{		
		return toAjax(quickHelpService.insertQuickHelp(quickHelp));
	}

	/**
	 * 修改帮助详情
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		QuickHelp quickHelp = quickHelpService.selectQuickHelpById(id);
		mmap.put("quickHelp", quickHelp);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存帮助详情
	 */
	@RequiresPermissions("sj:quickHelp:edit")
	@Log(title = "帮助详情", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(QuickHelp quickHelp)
	{		
		return toAjax(quickHelpService.updateQuickHelp(quickHelp));
	}
	
	/**
	 * 删除帮助详情
	 */
	@RequiresPermissions("sj:quickHelp:remove")
	@Log(title = "帮助详情", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(quickHelpService.deleteQuickHelpByIds(ids));
	}
	
}
